package com.yexiao.cofe.business.pojo;

import com.alibaba.fastjson2.JSONObject;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.yexiao.core.util.JSONUtil;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

/**
 * @author lkl
 * @since 2025/4/8
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@Accessors(chain = true)
@TableName("role")
public class Role {

    /**
     * 自增主键
     */
    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;

    /**
     * 角色名
     */
    @TableField(value = "role_name")
    private String roleName;

    /**
     * 排序字段
     */
    @TableField(value = "sort")
    private Integer sort;

    public static final String ID = "id";
    public static final String ROLE_NAME = "role_name";
    public static final String SORT = "sort";

    public Role(String roleName, Integer sort) {
        this.roleName = roleName;
        this.sort = sort;
    }

    public static JSONObject getBaseMsg(Role role) {
        return JSONUtil.of(
                "roleId", role.getId(),
                "roleName", role.getRoleName(),
                "sort", role.getSort()
        );
    }
}
